﻿package com.dLibs.utils
{
	/*
	Licensed under the MIT License
	Copyright (c) 2008 Pablo Davi
	Version: 0.1
	
	Description:	
	@ This class make infinite slider
	@ moving with mouse X and Y corditantes
	@ using duplicated movieCLip
	*/
	
	import flash.display.MovieClip;
	import flash.events.*;
	
	public class slideForever extends MovieClip
	{
		
		private var slideClip:MovieClip;
		private var distance:Number;
		private var speed:Number;
		
		public function addInfinite(_slideClip:MovieClip):void
		{
				slideClip = _slideClip;
				speed = 1/200;
				addEventListener(Event.ENTER_FRAME, makeSlider);
		}
		
		private function makeSlider(event:Event):void 
		{
			distance = mouseX - ((slideClip.parent.stage.stageWidth)/2);
			slideClip.x += (distance * speed);
			if (slideClip.x > 0) slideClip.x = -(slideClip.width/2);
			if (slideClip.x < -(slideClip.width/2)) slideClip.x = 0;
		}
	}
}